Skip to content

Infrastructure: pull requests where the code is found, complete runbooks where it is not; advisories only where they apply - #653

Closed
nambok wants to merge 2 commits into
mainfrom
infra-senior-engineer
Closed

nambok wants to merge 2 commits into
mainfrom
infra-senior-engineer

Conversation

@nambok

@nambok nambok commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Security, Infrastructure now works like an infrastructure engineer on a database, cache or search update: an update that has a code equivalent becomes a pull request against the line that sets the value, when the code that defines the resource is found for sure; an update that cannot be expressed in code, or whose code is not found, becomes a complete runbook that says why it is one.

Before this change every RDS, Aurora, ElastiCache and OpenSearch finding was a one-command runbook with no location, whatever defined the resource. The same CVE was shown on an operating system update, an Aurora PostgreSQL patch and a MySQL upgrade. A resource with a Terraform-generated identifier, or one defined through a module, was never found in code. Two actions on one cluster were unrelated rows and a second instance's action was dropped. RDS was read one page deep.

Changes

Correct findings (common/src/infra_vuln/actions.rs, raw.rs, matching.rs, feeds.rs)

  • A pending action is named for what it means on its ARN: system-update on an Aurora cluster ARN is an Aurora PostgreSQL engine patch, on an instance ARN an operating system update; os-upgrade and db-upgrade are read too. An action AWS does not document for an ARN is shown under AWS's own name with no meaning made up.
  • An advisory is attached only when it ties to the action: service, who acts, kind of action, engine and version range (or the update's own name), and date. An action AWS publishes with no CVE list (an operating system update) never gets a CVE; a recent bulletin that tells customers to patch the database OS is shown as related, and the card says AWS does not tie it to this action.
  • A bulletin's CVE list is what its title and summary name, not every CVE on the page.
  • One database's pending actions are one ordered set of rows. The same update listed on a cluster and on each instance is one row naming every ARN (readers first); two upgrades with different targets are one row for the higher. Each row says its place and why; where AWS gives no order the row says the order is CoderHelm's.
  • RDS clusters, instances and pending maintenance, and ElastiCache service updates, are read through every page.

Finding the code (locate.rs, terraform.rs, hcl.rs, stacks.rs, worker/src/passes/infra_inventory.rs, infra_repo.rs)

  • CloudFormation, CDK, SAM and Serverless Framework: the stack name and logical id from the resource's tags, or from DescribeStackResources by physical id where tags are missing, matched to the template that defines the logical id or the CDK construct the id was built from.
  • Terraform and OpenTofu: matched by resource type and attributes (identifier, a prefix with Terraform's generated suffix, engine, version, tags, subnet group), through local module calls, registry module calls and per-environment variable files. The edit target is where the value is written: the caller's input, a .tfvars line, a variable default. for_each, count and shared values are said so.
  • Files are recognised as infrastructure code by content (tool_of), so CDK next to application code, templates at neutral paths, serverless.yml and Pulumi programs count. is_iac_path is widened and is_iac(path, content) added.
  • Search names are ranked so every resource gets its strongest name before any gets a second (the alphabetical cap of 30 is gone). Every enabled repository is read (up to 30), every Terraform file within the caps, and what was not read is kept on the read's summary.
  • Every location records how it was found, a confidence (high, medium, low), the evidence and the other candidates. A low-confidence location never becomes a pull request.

Pull request or runbook (matching.rs, records.rs, guard.rs, worker/src/passes/infra_findings.rs)

  • Engine version changes, node group releases, AMIs and Lambda runtimes are pull requests when the code is found for sure; otherwise runbooks that say what was found and why it is unsure. Operating system updates, Aurora PostgreSQL patches, ElastiCache service updates and OpenSearch service software stay runbooks even when the resource is in code, and say so.
  • The ticket names the line to edit and what must never change. The pull request description carries, from the guidance: when the change takes effect, the expected interruption, what replaces the resource, what the plan must show, pre-checks, backup, rollback and known traps, each with its source.
  • The replacement guard reads a fix run's pull request before anything else happens to it. It trips on a change that would replace or destroy a data resource: a replacing attribute, a removed or renamed block, logical id or construct id, a lowered version, a version raised on a cluster member, an OpenSearch version change through CloudFormation or CDK without the version upgrade policy, a safeguard removed. Each reason names the file and the line. The pull request is never closed and its branch is never deleted:
    1. First trip: one fix round on the same branch, told each offending line and that it must produce the in-place change. The guard reads the result again.
    2. Second trip: the pull request is converted to draft, the reason and the lines go at the top of its description and on the finding, and the finding is shown as its runbook. The description section is a hold in ready.rs, so the pull request is never marked ready, and a draft is never merged. Every rebuild of the description keeps the section.
    3. No further automatic attempt until the finding's code (the line that sets the value) or its target changes. A person's own "fix" request starts a full cycle again.
  • The same resource in more than one environment: the non-production one goes first, both rows say so, and the production fix run waits unless AWS's date is within 7 days.

Runbooks and guidance (runbook.rs, guidance.rs, guidance/*.json)

  • A runbook has scope and exact identifiers, what it is, expected interruption, prerequisites and permissions, pre-checks, backup, console steps, CLI commands with the real identifiers and Region, validation, rollback and AWS's date. CoderHelm still never runs it.
  • Guidance is data: 180 entries, one per service, action and tool, each with a source link and a review date. Tests fail on an entry with no source or date. An entry not re-read for 180 days is flagged where it is shown. RDS and Aurora are covered in full; ElastiCache, OpenSearch, EKS node groups, AMIs and Lambda runtimes to the depth of the research.

AWS read permission

  • cloudformation:DescribeStackResources is added to the optional "Infrastructure vulnerabilities" ability (both access templates, log_reader.rs, iam_resource_types.json). It returns stack names and logical ids only. A role that does not have it yet is noted once on the read with the permission's name, and resources are placed by tags and code alone.

Shared files touched: services/worker/src/clients/github.rs (adds convert_pr_to_draft), services/worker/src/passes/ready.rs (one hold in body_holds_on), infra/cfn/coderhelm-log-reader.yaml, infra/cfn/coderhelm-log-reader-update.yaml, services/common/src/log_reader.rs, services/common/src/live/iam_resource_types.json, services/worker/src/passes/incidents/mod.rs, docs/incidents.md.

Where a pull request description is written: one call, update_pr_body in infra_findings::draft_with_reason (the draft reason). records::pr_body only builds text; pr.rs writes it as before. A test keeps it at one call.

Not in this change: Terraform state is not read (matches are graded instead). Engine version findings for ElastiCache, OpenSearch and MSK have guidance and a pull request path but no detection source yet: only RDS and Aurora db-upgrade actions raise one today. Nothing here was run against a live AWS account.

Verification

  • cargo fmt --check --all: clean. cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test --workspace: common 2,240 passed, gateway 907 passed, worker 1,734 passed (incident and replay suites included), 0 failed.
  • Unit tests: advisory matching, action labelling and reconciliation (actions.rs); each locator (CloudFormation tag and lookup, CDK logical id, Terraform resource, generated identifier, local and registry module, variable file, for_each) in locate.rs and terraform.rs; pull request versus runbook decisions and environment order (matching.rs); guidance validity and staleness (guidance.rs); runbook completeness (runbook.rs); the ticket, description and hold (records.rs).
  • The guard's steps: a_reason_names_the_file_and_the_line, the_fix_round_is_told_each_line_and_what_to_produce_instead, the_draft_section_sits_at_the_top_once_and_holds_the_pull_request (guard.rs); a_first_trip_is_one_fix_round_told_the_offending_line, a_fix_round_that_passes_the_guard_clears_the_refusal, a_second_trip_drafts_the_pull_request_and_falls_back_to_the_runbook, a_draft_stays_a_draft_through_later_description_rebuilds, no_further_attempt_until_the_code_or_the_target_changes (records.rs); a_tripped_guard_gets_one_fix_round_and_the_pull_request_stays_open, a_second_trip_makes_the_pull_request_a_draft_and_stops_automatic_attempts, the_draft_reason_holds_the_pull_request_and_nothing_closes_it_or_deletes_its_branch (infra_findings.rs).
  • Incident case an_six_database_findings: six database findings, one in Terraform with a generated identifier, one Aurora cluster defined through a module, a patch and an upgrade pending on the same cluster, more than one page of databases.
  • With the changed access templates: infra tests pass (180), Lambda tests pass (507), launch template tests pass (16), cfn-lint infra/cfn/*.yaml is clean. The self-hosted permissions boundary already allows the new read (cloudformation:* in BOUNDARY_SERVICES).
  • Not verified: nothing was run against a live AWS account or a live GitHub installation. The AWS SDK paging, the DescribeStackResources call, the reading of repositories, the queued fix round and the draft conversion are covered by type checks and by tests of the pure code they feed, not by a live run.

…oks where it is not; advisories only where they apply

A pending action is named for what it means on its ARN, and one database's
actions are one ordered set of rows. An advisory is attached only when it
ties to the action (service, engine, version range, kind of action, date);
an action AWS publishes with no CVE list gets none. RDS and ElastiCache
reads follow every page.

The code that defines a resource is found across every connected repository
and layout: CloudFormation, CDK, SAM and Serverless Framework by stack name
and logical id (tags, or DescribeStackResources by physical id), Terraform
and OpenTofu by resource type and attributes through module calls and
variable files. Each location says how it was found and how sure it is; a
low-confidence one never becomes a pull request.

An update with a code equivalent is a pull request on the line that sets
the value, with the rollout notes for its tool; one that cannot be
expressed in code stays a runbook and says so. A runbook is complete. A
change that would replace or destroy a data resource is refused. The facts
come from a guidance store with a source and a review date on every entry.

Adds cloudformation:DescribeStackResources to the optional Infrastructure
vulnerabilities read permissions.
…ound, then a draft with the reason and the runbook

The pull request is never closed and its branch is never deleted. On the
first trip one fix round is told each offending file and line and must
produce the in-place change; the guard reads the result again. If it still
trips, the pull request becomes a draft with the reason and the lines at
the top of its description, which holds it from being marked ready or
merged, and the finding falls back to its runbook. No further attempt
starts by itself until the finding's code or target changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant